<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../inc_min.jsp"></jsp:include>

    <meta http-equiv="X-UA-Compatible" content="edge" />
    <title>渠道管理-编辑</title>
    <style>
        ul,li{
            list-style: none;
        }
        a{
            text-decoration: none;
        }
        /* .controlSize{

             min-height:100px;
             _height:100px;
             padding:0;
         }*/
		table{
			margin:0 auto;
		}
		td{
			height:40px;
		}
        #tb{
            overflow:hidden;
            width:90%;
        }
        #tb ul{
            float:left;
            padding-left:0px;
        }
        #tb .list{
            width:150px;
            text-align:center;
            color:#3989c8;
        }

        #tb ul li{
            border:1px solid #dcdcdc;
            font-size:12px;
            height:30px;
            line-height:30px;
        }
        #buyerName{
        	font-weight:bold;
        	font-size:14px;
        }
        #tb .list_li li{
            text-align:center;
            border-left:none;
            padding-left:30px;
            padding-right:30px;
        }
        .impt{
            margin-top:5px;
            margin-bottom:5px;
        }
        .impt li{
            width:505px;
            height:30px;
            line-height:30px;
        }
        .textbox{
            height: 20px;
            margin: 0;
            padding: 0 2px;
            box-sizing: content-box;
            border: 1px solid #95B8E7;
            vertical-align: middle;

        }
        .blue_btn{
            border: none;
            border-radius: 3px;
            background-color: #3989c8;
            padding: 10px 10px;
            margin-right:5px;
            color:#fff;
        }
        .sub_btn{
            width:64px;
            border: none;
            border-radius: 3px;
            background-color: #ff8800;
            padding: 6px 6px;
            margin-right:10px;
            color:#fff;
        }
        .cancel_btn{
            width:64px;
            border: none;
            border-radius: 3px;
            padding: 6px 6px;
            margin-right:10px;
            color:white;
            background: #999999;
        }
        .panel combo-p{
            position: absolute;
            bottom:0;

        }
        #tb .list li + li{
            border-top:0px;
        }
        #tb .list_li li + li{
            border-top:0px;
        }
    </style>
    <script type="text/javascript">
        $(function(){
            //初始化页面
            $.ajax({
                type:"get",
                url:'${ctx}/charges/getById2/${param.id}?temp='+Math.random(),
                dataType:'json',
                async:true,
                success:function(data){
                    if(data.success){
                         $("#buyerName").text("采购商:"+data.obj.buyerName); //供应商
                         $("#orderTime").val(data.obj.orderTime); //非工作日机票款保留时长
                         $("#orderTimeForWork").val(data.obj.orderTimeForWork); //工作日机票款保留时长
                         $("#contractTime").val(data.obj.contractTime);  // 非工作日押金保留时长
                         $("#contractTimeForWork").val(data.obj.contractTimeForWork);  // 工作日押金保留时长
                         $("input[type='radio'][value="+data.obj.isAudit+"]").attr("checked",true);
                    }
                }
            });

        });



        function auditPay(){
            //验证机票款保留时长  必填
            var  orderTime = $("#orderTime").val();
            var  orderTimeForWork = $("#orderTimeForWork").val();
            var  contractTime = $("#contractTime").val();
            var  contractTimeForWork = $("#contractTimeForWork").val();
            var  isAudit =$("input[type='radio']:checked").val();
            if(orderTime == null || orderTime == "" || orderTime == "undefined"){
                layer.alert('请填写非工作日机票款保留时长', {
                    title:'友情提醒',
                    skin: 'layui-layer-lan', //样式类名
                    closeBtn: 0
                }, function(index){
                    layer.close(index);
                });
                return;
            }
            if(orderTimeForWork == null || orderTimeForWork == "" || orderTimeForWork == "undefined"){
                layer.alert('请填写工作日机票款保留时长', {
                    title:'友情提醒',
                    skin: 'layui-layer-lan', //样式类名
                    closeBtn: 0
                }, function(index){
                    layer.close(index);
                });
                return;
            }

            if(contractTime == null || contractTime == "" || contractTime == "undefined"){
                layer.alert('请填写非工作日押金保留时长', {
                    title:'友情提醒',
                    skin: 'layui-layer-lan', //样式类名
                    closeBtn: 0
                }, function(index){
                    layer.close(index);
                });
                return;
            }
            if(contractTimeForWork == null || contractTimeForWork == "" || contractTimeForWork == "undefined"){
                layer.alert('请填写工作日押金保留时长', {
                    title:'友情提醒',
                    skin: 'layui-layer-lan', //样式类名
                    closeBtn: 0
                }, function(index){
                    layer.close(index);
                });
                return;
            }

            progressLoad();
            var isValid = $('#dataForm').form('validate');
            if (!isValid) {
                progressClose();
                return;
            }

            var param={};//存储所有参数
            param={
                "id":"${param.id}",
                "orderTime":orderTime,
                "orderTimeForWork":orderTimeForWork,
                "contractTime":contractTime,
                "contractTimeForWork":contractTimeForWork,
                "isAudit":isAudit
            };

            //发送ajax请求
            $.ajax({
                type:"post",
                url:"${ctx}/charges/updateChannel?temp="+Math.random(),
                dataType:'json',
                //contentType:'application/json;charset=utf-8',
                data:param,
                success:function(data){
                    progressClose();
                    if(data.success){
                        layer.alert('编辑成功！',{skin:'layui-layer-lan',title: ['系统提示', 'background-color:#00B2EE; color:#fff;'],closeBtn: 0}, function(index){
                            closeWin();
                            layer.close(index);
                        });
                    }else{
                        layer.alert("编辑失败！");
                    }
                },
                error:function(msg){
                    progressClose();
                    layer.alert("请检查您的网络，并重试！");
                }
            });
        }
    </script>
</head>
<body style="padding-left:10px;padding-top:0px;">
<div id="tb">
    <h3 id="buyerName"></h3>
</div>
<form id="dataForm">
    <table border="0" style="margin-bottom: 50px">
        	<tr>
                <td align="right">工作日机票款保留时长（小时）：</td>
                <td>
                <input id="orderTimeForWork" style="width:295px;height:20px" type='number' min="1" class="textbox" />
                </td>
            </tr>
         <tr>
                <td align="right">非工作日机票款保留时长（小时）：</td>
                <td>
                <input id="orderTime" style="width:295px;height:20px" type='number' min="1" class="textbox" />
                </td>
            </tr>
            <tr>
                <td align="right">工作日押金保留时长（小时）：</td>
                <td>
                <input id="contractTimeForWork" style="width:295px;height:20px" type='number' min="1" class="textbox"/>
                </td>
            </tr>
         <tr>
                <td align="right">非工作日押金保留时长（小时）：</td>
                <td>
                <input id="contractTime" style="width:295px;height:20px" type='number' min="1" class="textbox"/>
                </td>
            </tr>
        <tr>
            <td align="right">散客订单审核：</td>
            <td>
                <input type="radio" name="single" value="0"> 关
                <input type="radio" name="single" value="1"> 开
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="button" value="提交" class="sub_btn" id="submit" onclick="auditPay()"/>
                <input type="button" value="取消" class="cancel_btn" id="close" onclick="closeWin()"/>
            </td>
        </tr>
    </table>
</form>
</body>
<link rel="stylesheet" href="${ctx}/jslib/layui/css/layui.css" media="all"/>
<script type="text/javascript" src="${ctx}/jslib/layer/layer.js" charset="utf-8"/>
</html>